package com.sjb.sixteen_journey_backend.controller;


import com.sjb.sixteen_journey_backend.common.R;
import com.sjb.sixteen_journey_backend.entity.HotelTicket;
import com.sjb.sixteen_journey_backend.service.IHotelTicketService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

/**
 * 酒店晒单表
 *
 * @author jcz
 * @since 2024-07-13
 */
@RestController
@RequestMapping("/hotel-ticket")
public class HotelTicketController {
    @Autowired
    private IHotelTicketService hotelTicketService;
    /**
     * 增加酒店晒单表
     * @param hotelTicket
     * @return
     */
    @PostMapping("/addHotelTicket")
    public R addHotelTicket(@RequestBody @Valid HotelTicket hotelTicket) {
        return hotelTicketService.addHotelTicket(hotelTicket);
    }
//    @PostMapping("/addHotelTicket")
//    public R addHotelTicket(@RequestBody HotelTicket hotelTicket, @RequestParam("image") ArrayList<MultipartFile> images) {
//        return hotelTicketService.addHotelTicket(hotelTicket, images);
//    }

    /**
     * 删除用户的一篇酒店晒单
     * @param id
     * @return
     */
    @DeleteMapping("/deleteHotelTicketById/{id}")
    public R deleteHotelTicketById(@PathVariable("id") Integer id ) {
        return hotelTicketService.deleteHotelTicketById(id);
    }

    /**
     * 获取所有酒店晒单
     * @return
     */
    @GetMapping("showAllHotelTicket")
    public R<List<HotelTicket>> showAllHotelTicket(){
        return hotelTicketService.showAllHotelTicket();
    }

    /**
     * 根据晒单id查酒店晒单
     * @param id 晒单id
     * @return
     */
    @GetMapping("showAllHotelTicketById/{id}")
    public R showAllHotelTicketById(@PathVariable("id") Integer id){
        return hotelTicketService.showAllHotelTicketById(id,true);
    }


    /**
     * 根据用户id获取所有酒店晒单
     * @return
     */
    @GetMapping("showAllHotelTicketByUserId")
    public R<List<HotelTicket>> showAllHotelTicketByUserId(){
        return hotelTicketService.showAllHotelTicketByUserId();
    }


}
